package com.biyu.monitormanage.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biyu.monitormanage.common.utils.PageUtils;
import com.biyu.monitormanage.common.utils.Query;
import com.biyu.monitormanage.dao.MonitorDao;
import com.biyu.monitormanage.entity.MachineEntity;
import com.biyu.monitormanage.entity.MonitorEntity;
import com.biyu.monitormanage.service.MonitorService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author 15491
 */
@Service("monitorService")
public class MonitorServiceImpl extends ServiceImpl<MonitorDao, MonitorEntity> implements MonitorService {

    @Override
    public PageUtils queryMonitor(Map<String, Object> params) {
        String monitorName = (String) params.get("monitorName");
        IPage<MonitorEntity> page = this.page(
                new Query<MonitorEntity>().getPage(params),
                new QueryWrapper<MonitorEntity>()
                        .like(StringUtils.isNoneBlank(monitorName), "monitor_name", monitorName)
        );

        return new PageUtils(page);
    }
}
